<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/shared.js"></script>
</head>
<body>
<script>

description("Regression test for WK82678 - don't commit after a blocked event");

indexedDBTest(prepareDatabase, holdConnection);
function prepareDatabase()
{
    db = event.target.result;
    evalAndLog("db.onversionchange = onVersionChange");
    evalAndLog("store = db.createObjectStore('store1')");
}

function holdConnection()
{
    debug("");
    debug("holdConnection():");
    debug("holding connection until versionchange event");
    debug("");
    worker = startWorker("resources/dont-commit-on-blocked-worker.js");
}

function onVersionChange(e)
{
    // Timing of logging from worker vs. this event is racy, so do not log here.
    // Don't close within this turn of the event loop, so that worker sees 'blocked'.
    setTimeout(function() {
        db.close();
    }, 0);
}

</script>
</body>
</html>
